﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FAQFrameworks;
using DTOFrameworks;
using System.Xml;
using AccessGrant;
using System.Data;
//using log4net;
//using log4net.Config;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            IDataElement dataElement = null;

            dataElement = Test1();

            foreach (IDataElement content in dataElement)
            {
                Console.WriteLine("{0}:{1}", content["@id"], content);
            }

            Console.WriteLine();

            dataElement = Test2();

            foreach (IDataElement content in dataElement)
            {
                Console.WriteLine("{0}:{1}",
                    content["id"], content["content"]);
            }
        }

        static IDataElement Test1()
        {
            string str = @"<contents>
<content id='1'>内容一</content>
<content id='2'>内容二</content>
<content id='3'>内容三</content>
</contents>";

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(str);


            XmlElementDataElement xde
                = new XmlElementDataElement(doc.DocumentElement);

            return xde["content"];
        }

        static IDataElement Test2()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Content", typeof(string));

            for (int i = 1; i <= 3; i++)
            {
                DataRow row = dt.NewRow();
                row["Id"] = i;
                row["Content"] = "内容" + i;

                dt.Rows.Add(row);
            }

            DataTableDataElement dtDE
                = new DataTableDataElement(dt);

            return dtDE;
        }
    }
}
